#pragma once
#include "const.h"

class HttpConnection;
typedef std::function<void(std::shared_ptr<HttpConnection>)>HttpHandler;

class LogicSystem :public Singleton<LogicSystem>
{
	friend class Singleton<LogicSystem>;
public:
	~LogicSystem();
	bool HandleGet(std::string path, std::shared_ptr<HttpConnection> handler);
	bool HandlePost(std::string path, std::shared_ptr<HttpConnection> handler);
	void RegGet(std::string url, HttpHandler handler);
	void RegPost(std::string url, HttpHandler handler);
	bool AnalyzeJson(std::shared_ptr<HttpConnection> connection, Json::Value& srcRoot, const std::string contextType);

	LogicSystem(const LogicSystem&) = delete;
	LogicSystem& operator = (const LogicSystem&) = delete;
private:
	LogicSystem();
	std::map<std::string, HttpHandler> _postHandlers;
	std::map<std::string, HttpHandler> _getHandlers;

};